#This is to get:
#tableA1a
#tableA1b
rm(list = ls())

library("xtable")
library("haven")


setwd("/Users/bgpopescu/Dropbox/Legacies_Central_Europe/")
setwd("C:/Users/bogdanp/Dropbox/Legacies_Central_Europe/")

#Reading data files
nutscollapsed<-read_dta("./data/nuts_data.dta")
lits<-read_dta("./data/lits_data.dta")
educdata<-read_dta("./data/educ_data.dta")

p_ottoman <-list("Prop. Ottoman", length(nutscollapsed$p_ottoman[!is.na(nutscollapsed$p_ottoman)]),
                 mean(nutscollapsed$p_ottoman, na.rm=T),
                 min(nutscollapsed$p_ottoman, na.rm=T), 
                 max(nutscollapsed$p_ottoman, na.rm=T), 
                 sd(nutscollapsed$p_ottoman, na.rm=T),
                 "NUTS-3")


lngdpcap <-list("Log GDP/cap", length(nutscollapsed$lngdpcap[!is.na(nutscollapsed$lngdpcap)]),
                mean(nutscollapsed$lngdpcap, na.rm=T),
                min(nutscollapsed$lngdpcap, na.rm=T), 
                max(nutscollapsed$lngdpcap, na.rm=T), 
                sd(nutscollapsed$lngdpcap, na.rm=T),
                "NUTS-3")

route_density_2 <-list("Trade Route Dens.", length(nutscollapsed$route_density_2[!is.na(nutscollapsed$route_density_2)]),
                       mean(nutscollapsed$route_density_2, na.rm=T),
                       min(nutscollapsed$route_density_2, na.rm=T), 
                       max(nutscollapsed$route_density_2, na.rm=T), 
                       sd(nutscollapsed$route_density_2, na.rm=T),
                       "NUTS-3")

tavg <-list("Annual Avg. Temp.", length(nutscollapsed$tavg[!is.na(nutscollapsed$tavg)]),
            mean(nutscollapsed$tavg, na.rm=T),
            min(nutscollapsed$tavg, na.rm=T), 
            max(nutscollapsed$tavg, na.rm=T), 
            sd(nutscollapsed$tavg, na.rm=T),
            "NUTS-3")


lograin <-list("Log Annual Avg. Rainfall", length(nutscollapsed$lograin[!is.na(nutscollapsed$lograin)]),
               mean(nutscollapsed$lograin, na.rm=T),
               min(nutscollapsed$lograin, na.rm=T), 
               max(nutscollapsed$lograin, na.rm=T), 
               sd(nutscollapsed$lograin, na.rm=T),
               "NUTS-3")


logelev <-list("Log Elevation", length(nutscollapsed$logelev[!is.na(nutscollapsed$logelev)]),
               mean(nutscollapsed$logelev, na.rm=T),
               min(nutscollapsed$logelev, na.rm=T), 
               max(nutscollapsed$logelev, na.rm=T), 
               sd(nutscollapsed$logelev, na.rm=T),
               "NUTS-3")


logslope <-list("Log Slope", length(nutscollapsed$logslope[!is.na(nutscollapsed$logslope)]),
                mean(nutscollapsed$logslope, na.rm=T),
                min(nutscollapsed$logslope, na.rm=T), 
                max(nutscollapsed$logslope, na.rm=T), 
                sd(nutscollapsed$logslope, na.rm=T),
                "NUTS-3")

point_x <-list("Longitude", length(nutscollapsed$point_x[!is.na(nutscollapsed$point_x)]),
               mean(nutscollapsed$point_x, na.rm=T),
               min(nutscollapsed$point_x, na.rm=T), 
               max(nutscollapsed$point_x, na.rm=T), 
               sd(nutscollapsed$point_x, na.rm=T),
               "NUTS-3")

point_y <-list("Latitude", length(nutscollapsed$point_y[!is.na(nutscollapsed$point_y)]),
               mean(nutscollapsed$point_y, na.rm=T),
               min(nutscollapsed$point_y, na.rm=T), 
               max(nutscollapsed$point_y, na.rm=T), 
               sd(nutscollapsed$point_y, na.rm=T),
               "NUTS-3")


lntmapplic <-list("Log Trade Mark Certifications per Capita", length(nutscollapsed$lntmapplic[!is.na(nutscollapsed$lntmapplic)]),
                  mean(nutscollapsed$lntmapplic, na.rm=T),
                  min(nutscollapsed$lntmapplic, na.rm=T), 
                  max(nutscollapsed$lntmapplic, na.rm=T), 
                  sd(nutscollapsed$lntmapplic, na.rm=T),
                  "NUTS-3")

firmscap <-list("Firms per Capita", length(nutscollapsed$firmscap[!is.na(nutscollapsed$firmscap)]),
                mean(nutscollapsed$firmscap, na.rm=T),
                min(nutscollapsed$firmscap, na.rm=T), 
                max(nutscollapsed$firmscap, na.rm=T), 
                sd(nutscollapsed$firmscap, na.rm=T),
                "NUTS-3")

firms10cap <-list("Firms >10 employees per Capita", length(nutscollapsed$firms10cap[!is.na(nutscollapsed$firms10cap)]),
                mean(nutscollapsed$firms10cap, na.rm=T),
                min(nutscollapsed$firms10cap, na.rm=T), 
                max(nutscollapsed$firms10cap, na.rm=T), 
                sd(nutscollapsed$firms10cap, na.rm=T),
                "NUTS-3")

secondaryed2 <-list("Share Pop. with Sec. Education", length(educdata$secondaryed2[!is.na(educdata$secondaryed2)]),
                    mean(educdata$secondaryed2, na.rm=T),
                    min(educdata$secondaryed2, na.rm=T), 
                    max(educdata$secondaryed2, na.rm=T), 
                    sd(educdata$secondaryed2, na.rm=T),
                    "NUTS-3")

p_ottoman_1800 <-list("Prop. Ottoman, 1800", length(nutscollapsed$p_ottoman_1800[!is.na(nutscollapsed$p_ottoman_1800)]),
                      mean(nutscollapsed$p_ottoman_1800, na.rm=T),
                      min(nutscollapsed$p_ottoman_1800, na.rm=T), 
                      max(nutscollapsed$p_ottoman_1800, na.rm=T), 
                      sd(nutscollapsed$p_ottoman_1800, na.rm=T),
                      "NUTS-3")

uni_1799 <-list("Universities, 1800", length(nutscollapsed$uni_1799[!is.na(nutscollapsed$uni_1799)]),
                mean(nutscollapsed$uni_1799, na.rm=T),
                min(nutscollapsed$uni_1799, na.rm=T), 
                max(nutscollapsed$uni_1799, na.rm=T), 
                sd(nutscollapsed$uni_1799, na.rm=T),
                "NUTS-3")

p_ottoman_1700 <-list("Prop. Ottoman, 1700", length(nutscollapsed$p_ottoman_1700[!is.na(nutscollapsed$p_ottoman_1700)]),
                      mean(nutscollapsed$p_ottoman_1700, na.rm=T),
                      min(nutscollapsed$p_ottoman_1700, na.rm=T), 
                      max(nutscollapsed$p_ottoman_1700, na.rm=T), 
                      sd(nutscollapsed$p_ottoman_1700, na.rm=T),
                      "NUTS-3")

ps_1699 <-list("Printshops, 1700", length(nutscollapsed$ps_1699[!is.na(nutscollapsed$ps_1699)]),
               mean(nutscollapsed$ps_1699, na.rm=T),
               min(nutscollapsed$ps_1699, na.rm=T), 
               max(nutscollapsed$ps_1699, na.rm=T), 
               sd(nutscollapsed$ps_1699, na.rm=T),
               "NUTS-3")


q109_1 <-list("Respondent's Highest Education Completed", length(lits$q109_1[!is.na(lits$q109_1)]),
              mean(lits$q109_1, na.rm=T),
              min(lits$q109_1, na.rm=T), 
              max(lits$q109_1, na.rm=T), 
              sd(lits$q109_1, na.rm=T),
              "Individual")

age_pr <-list("Respondent's Age", length(lits$age_pr[!is.na(lits$age_pr)]),
              mean(lits$age_pr, na.rm=T),
              min(lits$age_pr, na.rm=T), 
              max(lits$age_pr, na.rm=T), 
              sd(lits$age_pr, na.rm=T),
              "Individual")


gender_pr <-list("Respondent's Gender", length(lits$gender_pr[!is.na(lits$gender_pr)]),
                 mean(lits$gender_pr, na.rm=T),
                 min(lits$gender_pr, na.rm=T), 
                 max(lits$gender_pr, na.rm=T), 
                 sd(lits$gender_pr, na.rm=T),
                 "Individual")

urban <-list("Urban", length(lits$urban[!is.na(lits$urban)]),
             mean(lits$urban, na.rm=T),
             min(lits$urban, na.rm=T), 
             max(lits$urban, na.rm=T), 
             sd(lits$urban, na.rm=T),
             "Individual")


PRq315 <-list("Perception Income", length(lits$PRq315[!is.na(lits$PRq315)]),
             mean(lits$PRq315, na.rm=T),
             min(lits$PRq315, na.rm=T), 
             max(lits$PRq315, na.rm=T), 
             sd(lits$PRq315, na.rm=T),
             "Individual")

q109_2 <-list("2nd Respondent's Highest Education Completed", length(lits$q109_2[!is.na(lits$q109_2)]),
              mean(lits$q109_2, na.rm=T),
              min(lits$q109_2, na.rm=T), 
              max(lits$q109_2, na.rm=T), 
              sd(lits$q109_2, na.rm=T),
              "Individual")


q110_1 <-list("Father's Highest Education Completed", length(lits$q110_1[!is.na(lits$q110_1)]),
              mean(lits$q110_1, na.rm=T),
              min(lits$q110_1, na.rm=T), 
              max(lits$q110_1, na.rm=T), 
              sd(lits$q110_1, na.rm=T),
              "Individual")

q111_1 <-list("Mother's Highest Education Completed", length(lits$q111_1[!is.na(lits$q111_1)]),
              mean(lits$q111_1, na.rm=T),
              min(lits$q111_1, na.rm=T), 
              max(lits$q111_1, na.rm=T), 
              sd(lits$q111_1, na.rm=T),
              "Individual")

q203 <-list("No. Books in Childhood", length(lits$q203[!is.na(lits$q203)]),
            mean(lits$q203, na.rm=T),
            min(lits$q203, na.rm=T), 
            max(lits$q203, na.rm=T), 
            sd(lits$q203, na.rm=T),
            "Individual")

q801a <-list("Payments Road Police", length(lits$q801a[!is.na(lits$q801a)]),
            mean(lits$q801a, na.rm=T),
            min(lits$q801a, na.rm=T), 
            max(lits$q801a, na.rm=T), 
            sd(lits$q801a, na.rm=T),
            "Individual")

q801b <-list("Payments to get Offical Doc.", length(lits$q801b[!is.na(lits$q801b)]),
             mean(lits$q801b, na.rm=T),
             min(lits$q801b, na.rm=T), 
             max(lits$q801b, na.rm=T), 
             sd(lits$q801b, na.rm=T),
             "Individual")

q801d <-list("Payments to receive Public Edu. Primary or Sec.", length(lits$q801d[!is.na(lits$q801d)]),
             mean(lits$q801d, na.rm=T),
             min(lits$q801d, na.rm=T), 
             max(lits$q801d, na.rm=T), 
             sd(lits$q801d, na.rm=T),
             "Individual")


q801e <-list("Payments to receive Public Edu. Vocational", length(lits$q801e[!is.na(lits$q801e)]),
             mean(lits$q801e, na.rm=T),
             min(lits$q801e, na.rm=T), 
             max(lits$q801e, na.rm=T), 
             sd(lits$q801e, na.rm=T),
             "Individual")


q801f <-list("Payments to receive Public Health Treatment", length(lits$q801f[!is.na(lits$q801f)]),
             mean(lits$q801f, na.rm=T),
             min(lits$q801f, na.rm=T), 
             max(lits$q801f, na.rm=T), 
             sd(lits$q801f, na.rm=T),
             "Individual")


q801g <-list("Payments to receive Unemployment Benefits", length(lits$q801g[!is.na(lits$q801g)]),
             mean(lits$q801g, na.rm=T),
             min(lits$q801g, na.rm=T), 
             max(lits$q801g, na.rm=T), 
             sd(lits$q801g, na.rm=T),
             "Individual")


q801h <-list("Payments to receive Social Sec. Benefits", length(lits$q801h[!is.na(lits$q801h)]),
             mean(lits$q801h, na.rm=T),
             min(lits$q801h, na.rm=T), 
             max(lits$q801h, na.rm=T), 
             sd(lits$q801h, na.rm=T),
             "Individual")


q814c <-list("How many Gov. officials are Corrupt?", length(lits$q814c[!is.na(lits$q814c)]),
             mean(lits$q814c, na.rm=T),
             min(lits$q814c, na.rm=T), 
             max(lits$q814c, na.rm=T), 
             sd(lits$q814c, na.rm=T),
             "Individual")


q814d <-list("How many Loc Gov. Rep. are Corrupt?", length(lits$q814d[!is.na(lits$q814d)]),
             mean(lits$q814d, na.rm=T),
             min(lits$q814d, na.rm=T), 
             max(lits$q814d, na.rm=T), 
             sd(lits$q814d, na.rm=T),
             "Individual")


q405c <-list("Trust People You Meet First Time", length(lits$q405c[!is.na(lits$q405c)]),
             mean(lits$q405c, na.rm=T),
             min(lits$q405c, na.rm=T), 
             max(lits$q405c, na.rm=T), 
             sd(lits$q405c, na.rm=T),
             "Individual")


q423 <-list("Likelihood of Returning Wallet", length(lits$q423[!is.na(lits$q423)]),
             mean(lits$q423, na.rm=T),
             min(lits$q423, na.rm=T), 
             max(lits$q423, na.rm=T), 
             sd(lits$q423, na.rm=T),
            "Individual")


q428 <-list("Willingness to Take Risks", length(lits$q428[!is.na(lits$q428)]),
            mean(lits$q428, na.rm=T),
            min(lits$q428, na.rm=T), 
            max(lits$q428, na.rm=T), 
            sd(lits$q428, na.rm=T),
            "Individual")


workeffort <-list("Need Effort and Intelligence to Succeed", length(lits$workeffort[!is.na(lits$workeffort)]),
            mean(lits$workeffort, na.rm=T),
            min(lits$workeffort, na.rm=T), 
            max(lits$workeffort, na.rm=T), 
            sd(lits$workeffort, na.rm=T),
            "Individual")


democracy <-list("Democracy is Preferable", length(lits$democracy[!is.na(lits$democracy)]),
                  mean(lits$democracy, na.rm=T),
                  min(lits$democracy, na.rm=T), 
                  max(lits$democracy, na.rm=T), 
                  sd(lits$democracy, na.rm=T),
                 "Individual")


q417c <-list("Competition is Harmful", length(lits$q417c[!is.na(lits$q417c)]),
                 mean(lits$q417c, na.rm=T),
                 min(lits$q417c, na.rm=T), 
                 max(lits$q417c, na.rm=T), 
                 sd(lits$q417c, na.rm=T),
             "Individual")


q417b <-list("Private Ownership is Good", length(lits$q417b[!is.na(lits$q417b)]),
             mean(lits$q417b, na.rm=T),
             min(lits$q417b, na.rm=T), 
             max(lits$q417b, na.rm=T), 
             sd(lits$q417b, na.rm=T),
             "Individual")



marketeconomy <-list("Market Economy is Good", length(lits$marketeconomy[!is.na(lits$marketeconomy)]),
             mean(lits$marketeconomy, na.rm=T),
             min(lits$marketeconomy, na.rm=T), 
             max(lits$marketeconomy, na.rm=T), 
             sd(lits$marketeconomy, na.rm=T),
             "Individual")

q404b <-list("Trust Government", length(lits$q404b[!is.na(lits$q404b)]),
                     mean(lits$q404b, na.rm=T),
                     min(lits$q404b, na.rm=T), 
                     max(lits$q404b, na.rm=T), 
                     sd(lits$q404b, na.rm=T),
             "Individual")

q404h <-list("Trust Army", length(lits$q404h[!is.na(lits$q404h)]),
             mean(lits$q404h, na.rm=T),
             min(lits$q404h, na.rm=T), 
             max(lits$q404h, na.rm=T), 
             sd(lits$q404h, na.rm=T),
             "Individual")

q404j <-list("Trust Banks", length(lits$q404j[!is.na(lits$q404j)]),
             mean(lits$q404j, na.rm=T),
             min(lits$q404j, na.rm=T), 
             max(lits$q404j, na.rm=T), 
             sd(lits$q404j, na.rm=T),
             "Individual")


q404k <-list("Trust Foreign Investors", length(lits$q404k[!is.na(lits$q404k)]),
             mean(lits$q404k, na.rm=T),
             min(lits$q404k, na.rm=T), 
             max(lits$q404k, na.rm=T), 
             sd(lits$q404k, na.rm=T),
             "Individual")

###################
#ROMANIA DATA 1930#
###################
data_1930 <- read.csv(file = './data/data_ro_1930.csv')

#####################################
#Preparing Sumstat Romanian Counties#
#####################################

dist_ottoman_brd <-list("Distance to Ottoman-Habsburg Border", 
                    length(data_1930$Ott_Habs_brd_distance[!is.na(data_1930$Ott_Habs_brd_distance)]),
                    mean(data_1930$Ott_Habs_brd_distance, na.rm=T),
                    min(data_1930$Ott_Habs_brd_distance, na.rm=T), 
                    max(data_1930$Ott_Habs_brd_distance, na.rm=T), 
                    sd(data_1930$Ott_Habs_brd_distance, na.rm=T),
                    "County Romania")


tavg_mean_ro <-list("Average Temperature", 
                    length(data_1930$tavg_mean[!is.na(data_1930$tavg_mean)]),
             mean(data_1930$tavg_mean, na.rm=T),
             min(data_1930$tavg_mean, na.rm=T), 
             max(data_1930$tavg_mean, na.rm=T), 
             sd(data_1930$tavg_mean, na.rm=T),
             "County Romania")


prec_mean_ro <-list("Average Annual Rainfall", 
                    length(data_1930$prec_mean[!is.na(data_1930$prec_mean)]),
                    mean(data_1930$prec_mean, na.rm=T),
                    min(data_1930$prec_mean, na.rm=T), 
                    max(data_1930$prec_mean, na.rm=T), 
                    sd(data_1930$prec_mean, na.rm=T),
                    "County Romania")


elev <-list("Elevation", 
                    length(data_1930$elev[!is.na(data_1930$elev)]),
                    mean(data_1930$elev, na.rm=T),
                    min(data_1930$elev, na.rm=T), 
                    max(data_1930$elev, na.rm=T), 
                    sd(data_1930$elev, na.rm=T),
            "County Romania")

slope <-list("Slope", 
            length(data_1930$slope[!is.na(data_1930$slope)]),
            mean(data_1930$slope, na.rm=T),
            min(data_1930$slope, na.rm=T), 
            max(data_1930$slope, na.rm=T), 
            sd(data_1930$slope, na.rm=T),
            "County Romania")

pct_flotant <-list("Migrant population 1930", 
             length(data_1930$pct_flotant[!is.na(data_1930$pct_flotant)]),
             mean(data_1930$pct_flotant, na.rm=T),
             min(data_1930$pct_flotant, na.rm=T), 
             max(data_1930$pct_flotant, na.rm=T), 
             sd(data_1930$pct_flotant, na.rm=T),
             "County Romania")


route_density <-list("Trade Route Density 1450", 
                   length(data_1930$route_density[!is.na(data_1930$route_density)]),
                   mean(data_1930$route_density, na.rm=T),
                   min(data_1930$route_density, na.rm=T), 
                   max(data_1930$route_density, na.rm=T), 
                   sd(data_1930$route_density, na.rm=T),
                   "County Romania")


pct_romanian <-list("Pct. Romanian 1930", 
                   length(data_1930$pct_romanian[!is.na(data_1930$pct_romanian)]),
                   mean(data_1930$pct_romanian, na.rm=T),
                   min(data_1930$pct_romanian, na.rm=T), 
                   max(data_1930$pct_romanian, na.rm=T), 
                   sd(data_1930$pct_romanian, na.rm=T),
                   "County Romania")


pct_hungarian <-list("Pct. Hungarian 1930", 
                    length(data_1930$pct_hungarian[!is.na(data_1930$pct_hungarian)]),
                    mean(data_1930$pct_hungarian, na.rm=T),
                    min(data_1930$pct_hungarian, na.rm=T), 
                    max(data_1930$pct_hungarian, na.rm=T), 
                    sd(data_1930$pct_hungarian, na.rm=T),
                    "County Romania")



pct_german<-list("Pct. German 1930", 
                 length(data_1930$pct_german[!is.na(data_1930$pct_german)]),
                 mean(data_1930$pct_german, na.rm=T),
                 min(data_1930$pct_german, na.rm=T), 
                 max(data_1930$pct_german, na.rm=T), 
                 sd(data_1930$pct_german, na.rm=T),
                 "County Romania")


pct_literate_1930<-list("Pct. Literate 1930", 
                 length(data_1930$alfabet[!is.na(data_1930$alfabet)]),
                 mean(data_1930$alfabet, na.rm=T),
                 min(data_1930$alfabet, na.rm=T), 
                 max(data_1930$alfabet, na.rm=T), 
                 sd(data_1930$alfabet, na.rm=T),
                 "County Romania")


########################
#ROMANIAN COUNTIES 1880#
########################
data_1880 <- read.csv(file = './data/data_ro_1880.csv')

pct_literate_1880<-list("Pct. Literate 1880", 
                        length(data_1880$pct_literate[!is.na(data_1880$pct_literate)]),
                        mean(data_1880$pct_literate, na.rm=T),
                        min(data_1880$pct_literate, na.rm=T), 
                        max(data_1880$pct_literate, na.rm=T), 
                        sd(data_1880$pct_literate, na.rm=T),
                        "County Romania")



########################
#ROMANIAN COUNTIES 1910#
########################
data_1910 <- read.csv(file = './data/data_ro_1910.csv')

pct_literate_1910<-list("Pct. Literate 1910", 
                        length(data_1910$pct_literate[!is.na(data_1910$pct_literate)]),
                        mean(data_1910$pct_literate, na.rm=T),
                        min(data_1910$pct_literate, na.rm=T), 
                        max(data_1910$pct_literate, na.rm=T), 
                        sd(data_1910$pct_literate, na.rm=T),
                        "County Romania")


#########################
#ROMANIAN COUNTIES, 1948#
#########################
data_1948 <- read.csv(file = './data/data_ro_1948.csv')

pct_literate_1948<-list("Pct. Literate 1948", 
                        length(data_1948$pct_literate[!is.na(data_1948$pct_literate)]),
                        mean(data_1948$pct_literate, na.rm=T),
                        min(data_1948$pct_literate, na.rm=T), 
                        max(data_1948$pct_literate, na.rm=T), 
                        sd(data_1948$pct_literate, na.rm=T),
                        "County Romania")


##########
#SUMSTAT1#
##########

sd<-as.data.frame(rbind(p_ottoman,
                        lngdpcap,
                        route_density_2,
                        tavg,
                        lograin,
                        logelev,
                        logslope,
                        point_x,
                        point_y,
                        lntmapplic,
                        firmscap,
                        firms10cap,
                        lntmapplic,
                        secondaryed2,
                        q109_1,
                        age_pr,
                        gender_pr,
                        urban,
                        PRq315,
                        q109_2,
                        q110_1,
                        q111_1,
                        q203,
                        p_ottoman_1800,
                        uni_1799,
                        p_ottoman_1700,
                        ps_1699,
                        q801a,
                        q801b,
                        q801d,
                        q801e,
                        q801f,
                        q801g,
                        q801h,
                        q814c,
                        q814d,
                        q405c,
                        q423,
                        q428,
                        workeffort,
                        democracy,
                        q417c,
                        q417b,
                        marketeconomy,
                        q404b,
                        q404h,
                        q404j,
                        q404k))
colnames(sd)<-c("Variable", "N", "Mean", "Min", "Max", "SD", "Unit Analysis")
rownames(sd) <- NULL

library(xtable)

ncol(sd)
object_latex<-xtable(sd, type = "latex", caption = "Summary Statistics", digits=c(0,0,0,3,3,3,3, 0))
align(object_latex) <- xalign(object_latex)

large <- function(x){
  paste0('{\\bfseries ', x, '}') }
italic <- function(x){ paste0('{\\emph{ ', x, '}}')
}


setwd("./Paper/tables")

print(object_latex, file = "tableA1a.tex", 
      caption.placement = "top",
      sanitize.colnames.function = large,
      booktabs = TRUE,
      include.rownames=FALSE)



############
#SUMSTAT 2#
###########


sd<-as.data.frame(rbind(dist_ottoman_brd,
                        tavg_mean_ro,
                        prec_mean_ro,
                        elev,
                        slope,
                        pct_flotant,
                        route_density,
                        pct_romanian,
                        pct_hungarian,
                        pct_german,
                        pct_literate_1880,
                        pct_literate_1910,
                        pct_literate_1930,
                        pct_literate_1948))
colnames(sd)<-c("Variable", "N", "Mean", "Min", "Max", "SD", "Unit Analysis")
rownames(sd) <- NULL

library(xtable)

ncol(sd)
object_latex<-xtable(sd, type = "latex", caption = "Summary Statistics - \\textit{Continued}", digits=c(0,0,0,3,3,3,3, 0))
align(object_latex) <- xalign(object_latex)

large <- function(x){
  paste0('{\\bfseries ', x, '}') }
italic <- function(x){ paste0('{\\emph{ ', x, '}}')
}


setwd("./Paper/tables")

print(object_latex, file = "tableA1b.tex", 
      caption.placement = "top",
      sanitize.colnames.function = large,
      booktabs = TRUE,
      include.rownames=FALSE)


